package KK.KKQueue
{
	public class KKQueue implements IKKQueue
	{
		
		private var queue:Vector.<IKKQueueObject>;
		private var priorityQueue:Vector.<IKKQueueObject>;
		public function KKQueue()
		{
			//TODO: implement function
			init();
		}
		private function init():void{
			queue=new Vector.<IKKQueueObject>();
			priorityQueue=new Vector.<IKKQueueObject>;
		}
		
		/**
		 * 添加队列 
		 * @param msg
		 * 
		 */
		public function AddQueue(msg:IKKQueueObject):void
		{
			queue.push(msg);
		}
		
		/**
		 * 添加优先队列 
		 * @param msg
		 * 
		 */
		public function AddPriority(msg:IKKQueueObject):void
		{
			priorityQueue.push(msg); 
		}
		
		/**
		 * 窃取消息 
		 * @return 
		 * 
		 */
		public function PeekQueue():IKKQueueObject
		{ 
			//TODO: implement function
			var result:IKKQueueObject;
			if(priorityQueue.length>0){
				result=priorityQueue.shift();
			}else{
				result=queue.shift();
			}
			return result;
		}
		 
	}
}